Skip to content

Updated next js version#403

Open
akshay0611 wants to merge 2 commits intomainfrom
feat/opensource
Open

Updated next js version#403
akshay0611 wants to merge 2 commits intomainfrom
feat/opensource

Conversation

@akshay0611
Copy link
Copy Markdown
Collaborator

@akshay0611 akshay0611 commented Mar 21, 2026

Summary by CodeRabbit

  • New Features
    • Analytics integration has been added to the application for tracking and insights.

vercel bot and others added 2 commits March 21, 2026 17:15
## Vercel Web Analytics Installation

Successfully installed and configured Vercel Web Analytics for this Next.js project.

### Changes Made

1. **Installed @vercel/analytics package**
   - Added `@vercel/analytics` v2.0.1 to dependencies
   - Updated package-lock.json with the new dependency

2. **Configured Analytics Component**
   - Modified `app/layout.tsx` to import and use the Analytics component
   - Added `import { Analytics } from '@vercel/analytics/react'` at the top
   - Placed `<Analytics />` component in the body section of the root layout
   - Followed Next.js App Router best practices as specified in the official Vercel documentation

### Implementation Details

According to the official Vercel Analytics quickstart guide (https://vercel.com/docs/analytics/quickstart), the implementation for Next.js App Router requires:

1. Installing the package: `npm install @vercel/analytics`
2. Importing from `@vercel/analytics/react` (not `@vercel/analytics/next` for client components)
3. Adding the `<Analytics />` component to the root layout

Since the root layout uses `'use client'` directive, we imported from `@vercel/analytics/react` which is the correct import for client components.

The Analytics component was placed at the end of the body section, after all other components, which ensures it doesn't interfere with the application's rendering and user experience.

### Testing & Verification

- ✅ Package installed successfully
- ✅ Code linting passed with no new errors
- ✅ Changes follow existing code patterns and conventions
- ✅ Build process validated (existing Supabase env var issue is unrelated to our changes)

### Next Steps

To complete the setup:
1. Deploy the application to Vercel
2. Enable Analytics in the Vercel dashboard (Project Settings → Analytics → Enable)
3. After deployment, verify analytics data collection by checking the browser's Network tab for requests to the analytics endpoint
4. Data will appear in the Vercel dashboard after a few days of visitor activity

### Files Modified

- `app/layout.tsx` - Added Analytics import and component
- `package.json` - Added @vercel/analytics dependency
- `package-lock.json` - Updated with new dependency tree

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codeunia Building Building Preview, Comment Mar 21, 2026 11:50am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 21, 2026

📝 Walkthrough

Walkthrough

Added Vercel Analytics integration by introducing the @vercel/analytics dependency and rendering the Analytics component in the root layout. Updated Next.js to version range ^15.5.14 and bumped jest-environment-jsdom to ^30.3.0.

Changes

Cohort / File(s) Summary
Analytics Integration
app/layout.tsx
Imported and rendered <Analytics /> component from @vercel/analytics/react within RootLayout, positioned alongside existing global UI components.
Dependency Updates
package.json
Added @vercel/analytics at ^2.0.1; updated Next.js from fixed version 15.5.9 to range ^15.5.14; bumped jest-environment-jsdom from ^29.7.0 to ^30.3.0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 hop hop, analytics now gleam bright,
Vercel's gift to track the night,
Dependencies dance in perfect verse,
Next.js flows, not in reverse! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Updated next js version' is partially related to the changeset but does not capture the main change—it mentions only the Next.js update while omitting the addition of Vercel Analytics, which is also a significant change. Revise the title to reflect both main changes, such as 'Add Vercel Analytics and update Next.js version' or focus on the primary change if Vercel Analytics integration is the main objective.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/opensource

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/layout.tsx`:
- Line 9: The <Analytics /> component in app/layout.tsx must be rendered only
when the user has given consent: import and call the consent helper (e.g.
getAnalyticsConsent or hasAnalyticsConsent from lib/analytics-cookies.ts) and
conditionally render <Analytics /> only if it returns true; ensure this check
runs client-side (wrap the analytics rendering in a client component or use a
useEffect/hydration check) so analytics is never mounted before stored consent
is confirmed.

In `@package.json`:
- Around line 161-162: package.json currently pins "jest" to ^29.7.0 while
"jest-environment-jsdom" is ^30.3.0 causing an incompatible major version
mismatch; choose one approach and apply it consistently: either set
"jest-environment-jsdom" to a 29.x release to match "jest" (change the
dependency value for jest-environment-jsdom to ^29.x) or upgrade "jest" to ^30.x
and then audit and update any Jest-related tooling (transformers, presets,
ts-jest, babel-jest, etc.) to versions compatible with Jest 30; update the
package.json entries for "jest" and/or "jest-environment-jsdom" accordingly and
run npm/yarn install and the test suite to verify compatibility.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 160bb14b-f63d-4e14-a78d-ad39394a9a06

📥 Commits

Reviewing files that changed from the base of the PR and between 249b780 and acf60af.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • app/layout.tsx
  • package.json

import AIProvider from "@/components/ai/AIProvider";
import { getPageStructuredData } from "@/lib/seo/metadata";
import { usePathname } from "next/navigation";
import { Analytics } from '@vercel/analytics/react';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Gate Vercel Analytics behind stored consent before rendering.

Line 92 mounts <Analytics /> for every user, but your consent model (lib/analytics-cookies.ts:44-50, lib/analytics-cookies.ts:53-60) defaults analytics to off and exposes a consent check. This can trigger tracking before consent.

🔧 Suggested fix
+import { useEffect, useState } from "react";
 import { Analytics } from '@vercel/analytics/react';
+import { analyticsCookies } from "@/lib/analytics-cookies";

 export default function RootLayout({
   children,
 }: Readonly<{
   children: React.ReactNode;
 }>) {
+  const [canTrackAnalytics, setCanTrackAnalytics] = useState(false);
+
+  useEffect(() => {
+    setCanTrackAnalytics(analyticsCookies.hasConsent());
+  }, []);
+
   const structuredData = getPageStructuredData('home');
   const pathname = usePathname();

@@
-            <Analytics />
+            {canTrackAnalytics && <Analytics />}
           </ThemeProvider>

Also applies to: 92-92

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/layout.tsx` at line 9, The <Analytics /> component in app/layout.tsx must
be rendered only when the user has given consent: import and call the consent
helper (e.g. getAnalyticsConsent or hasAnalyticsConsent from
lib/analytics-cookies.ts) and conditionally render <Analytics /> only if it
returns true; ensure this check runs client-side (wrap the analytics rendering
in a client component or use a useEffect/hydration check) so analytics is never
mounted before stored consent is confirmed.

Comment on lines 161 to +162
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-environment-jsdom": "^30.3.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "package.json dev dependency versions:"
jq -r '.devDependencies.jest, .devDependencies["jest-environment-jsdom"]' package.json

echo
echo "Published peerDependencies for jest-environment-jsdom@30.3.0:"
curl -s https://registry.npmjs.org/jest-environment-jsdom/30.3.0 | jq '.peerDependencies'

Repository: codeunia-dev/codeunia

Length of output: 206


🌐 Web query:

jest 29 jest-environment-jsdom 30 compatibility

💡 Result:

No, Jest 29 is not compatible with jest-environment-jsdom 30. Jest 29 uses jest-environment-jsdom ^29.x (which depends on jsdom ^20), while jest-environment-jsdom 30 is designed for Jest 30 and upgrades to jsdom v22+ (up to v26), introducing breaking changes in DOM behavior. Using the mismatched versions will likely cause test failures due to API incompatibilities between Jest core and the environment, as evidenced by official upgrade guides and release notes that treat this as a major version upgrade requiring Jest 30. Some users mix Jest 30 with jest-environment-jsdom 29 to avoid JSDOM 22+ issues, confirming the versions are not interchangeable.

Citations:


Align jest-environment-jsdom major version with jest major version.

Line 162 upgrades jest-environment-jsdom to 30.x while Line 161 keeps jest at 29.x. Jest 29 and jest-environment-jsdom 30 are incompatible—jest-environment-jsdom 30 depends on jsdom 22+ (versus 20.x in the 29 line) and introduces breaking changes in DOM behavior. This mismatch will cause test failures.

Choose one approach:

Option 1: Downgrade jest-environment-jsdom to 29.x
-    "jest-environment-jsdom": "^30.3.0",
+    "jest-environment-jsdom": "^29.7.0",
Option 2: Upgrade jest to 30.x (and audit related Jest tooling)

Upgrade jest to ^30.x and ensure other Jest-related dependencies also support Jest 30.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-environment-jsdom": "^30.3.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 161 - 162, package.json currently pins "jest" to
^29.7.0 while "jest-environment-jsdom" is ^30.3.0 causing an incompatible major
version mismatch; choose one approach and apply it consistently: either set
"jest-environment-jsdom" to a 29.x release to match "jest" (change the
dependency value for jest-environment-jsdom to ^29.x) or upgrade "jest" to ^30.x
and then audit and update any Jest-related tooling (transformers, presets,
ts-jest, babel-jest, etc.) to versions compatible with Jest 30; update the
package.json entries for "jest" and/or "jest-environment-jsdom" accordingly and
run npm/yarn install and the test suite to verify compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant